import java.util.*;

/**
 * @author: shiding
 * @data: 2022/5/15 21:46
 **/
public class DeleteDuplicates {


    public static void main(String[] args) {
        ListNode listNode = new ListNode();
        listNode.val = 1;
        listNode.next = new ListNode(1, new ListNode(2));
        ListNode listNode1 = deleteDuplicates(listNode);
        System.out.println(listNode1.toString());

    }

    public static ListNode deleteDuplicates(ListNode nodes) {
        ListNode temp = nodes;
         while (temp.next != null) {
             if (temp.val == temp.next.val) {
                 temp.next = temp.next.next;
             } else {
                 temp = temp.next;
             }
         }
        return nodes;
    }



public static class ListNode {
    int val;
    ListNode next;
    ListNode() {}
    ListNode(int val) { this.val = val; }
    ListNode(int val, ListNode next) { this.val = val; this.next = next; }
}


}

